<?php
require_once(dirname(__FILE__)."/config.php");
CheckPurview('member_Convert');
require_once(DEDEINC."/datalistcp.class.php");
setcookie("ENV_GOBACK_URL",$dedeNowurl,time()+3600,"/");


if(!isset($dopost))
{
	$dopost = '';
}
if($dopost=='')
{
	$status = '';
	if(isset($check)){
		$status = "and status = $check";
	}
	$query = "Select * From `#@__member_convert` where 1=1  {$status} order by id desc";
	$dlist = new DataListCP();
	$dlist->pageSize = 20;
	$dlist->SetTemplet(DEDEADMIN."/templets/member_convert.htm");
	$dlist->SetSource($query);
	$dlist->Display();
}
elseif($dopost=='del')
{
	$ids = ereg_replace("[^0-9,]","",$ids);
	if(is_int($ids)){
		$query = "Delete From `#@__member_convert` where id = $ids";
	}else{
		$query = "Delete From `#@__member_convert` where id in($ids)";
	}
	$dsql->ExecuteNoneQuery($query);
	ShowMsg("删除成功！","member_convert.php");
	exit();
}elseif($dopost=='check')
{
	$id = intval($id);
	$remark = htmlspecialchars(addslashes(trim($remark)));
	$query = "Select * From `#@__member_convert` where 1=1  and id = $id";
	$convert_info = $dsql->getOne($query);
	if(!empty($convert_info) && count($convert_info) > 0){
		$query1 = "Update `#@__member_convert` set status=1,check_time=".time().",remark='$remark' where id = $id";
		//$query2 = "Update `#@__member` set scores = scores-{$convert_info['scores']} where mid = '{$convert_info['mid']}'";
		$dsql->ExecuteNoneQuery($query1);
		//$dsql->ExecuteNoneQuery($query2);
		ShowMsg("审核成功！","member_convert.php");
	}else{
		ShowMsg("该条数据不存在！","member_convert.php");
	}
}elseif($dopost=='view'){
	$query = "Select * From `#@__member_convert` where 1=1  and id = $id";
	$convert_info = $dsql->getOne($query);
	$convert_info['userinfo'] = $dsql->getOne("Select * From `#@__member` m inner join `#@__member_person` p on m.mid=p.mid and m.mid = {$convert_info['mid']}");
	include DedeInclude('templets/member_convert_view.htm');
}
/*if(!isset($sex)) $sex = '';
if(!isset($mtype)) $mtype = '';
if(!isset($spacesta)) $spacesta = -10;
if(!isset($matt)) $matt = 10;

if(!isset($keyword)) $keyword = '';
else $keyword = trim(FilterSearch($keyword));

$mtypeform = empty($mtype) ? "<option value=''>类型</option>\r\n" : "<option value='$mtype'>$mtype</option>\r\n";
$sexform = empty($sex) ? "<option value=''>性别</option>\r\n" : "<option value='$sex'>$sex</option>\r\n";
$sortkey = empty($sortkey) ? 'mid' : eregi_replace('[^a-z]','',$sortkey);

$staArr = array(-2=>'限制用户(禁言)', -1=>'未通过审核', 0=>'审核通过，提示填写完整信息', 1=>'没填写详细资料', 2=>'正常使用状态');
$staArrmatt = array(1=>'被推荐', 0=>'非普通 ' );
$MemberTypes = array();
$dsql->SetQuery("Select rank,membername From `#@__arcrank` where rank>0 ");
$dsql->Execute();
while($row = $dsql->GetObject())
{
	$MemberTypes[$row->rank] = $row->membername;
}

if($sortkey=='mid')
{
	$sortform = "<option value='mid'>mid/注册时间</option>\r\n";
}
else if($sortkey=='rank')
{
	$sortform = "<option value='rank'>会员等级</option>\r\n";
}
else if($sortkey=='money')
{
	$sortform = "<option value='money'>会员金币</option>\r\n";
}
else if($sortkey=='scores')
{
	$sortform = "<option value='scores'>会员积分</option>\r\n";
}
else
{
	$sortform = "<option value='logintime'>登录时间</option>\r\n";
}

$wheres[] = " (userid like '%$keyword%' Or uname like '%$keyword%' Or email like '%$keyword%') ";

if($sex   != '')
{
	$wheres[] = " sex like '$sex' ";
}

if($mtype != '')
{
	$wheres[] = " mtype like '$mtype' ";
}

if($spacesta != -10)
{
	$wheres[] = " spacesta = '$spacesta' ";
}

if($matt != 10)
{
	$wheres[] = " matt= '$matt' ";
}

$whereSql = join(' And ',$wheres);
if($whereSql!='')
{
	$whereSql = ' where '.$whereSql;
}
$dsql->SetQuery("Select name From `#@__member_model`");
$dsql->Execute();
while($row = $dsql->GetArray())
{
	$MemberModels[] = $row;
}

$sql  = "select * From `#@__member` $whereSql order by $sortkey desc ";
$dlist = new DataListCP();
$dlist->SetParameter('sex',$sex);
$dlist->SetParameter('spacesta',$spacesta);
$dlist->SetParameter('matt',$matt);
$dlist->SetParameter('mtype',$mtype);
$dlist->SetParameter('sortkey',$sortkey);
$dlist->SetParameter('keyword',$keyword);
$dlist->SetTemplet(DEDEADMIN."/templets/member_convert.htm");
$dlist->SetSource($sql);
$dlist->display();

function GetMemberName($rank,$mt)
{
	global $MemberTypes;
	if(isset($MemberTypes[$rank]))
	{
		if($mt=='ut') return " <font color='red'>待升级：".$MemberTypes[$rank]."</font>";
		else return $MemberTypes[$rank];
	}
	else
	{
		if($mt=='ut') return '';
		else return $mt;
	}
}

function GetMAtt($m)
{
	if($m<1) return '';
	else if($m==10) return "&nbsp;<font color='red'>[管理员]</font>";
	else return "&nbsp;<img src='img/adminuserico.gif' wmidth='16' height='15'><font color='red'>[荐]</font>";
}
*/
?>